#pragma once
#include "SFML\System.hpp"
#include "VisibleGameObject.h"

class GameObjectCache
{
public:
	GameObjectCache();
	~GameObjectCache();

	void Add(std::string name, VisibleGameObject* gameObject);
	void Remove(std::string name);
	int GetObjectCount() const;
	VisibleGameObject* Get(std::string name) const;

	void DrawAll(sf::RenderWindow& renderWindow);
	void UpdateAll();
	void CheckCollisions();
	void Pause(bool isPaused);

private:
	sf::Clock _clock;

	std::map<std::string, VisibleGameObject*> _gameObjects;
	std::map<std::string, CollidableObject*> _collidableObjects;

	struct GameObjectDeallocator
	{
		void operator()(const std::pair<std::string, VisibleGameObject*> & p) const
		{
			delete p.second;
		}
	};
};

